let student=require("./student");
let teacher=require("./teacher");
module.exports=class klass{
    constructor(number){
        this.number=number;
    }
    getDisplayName(){
        return "Class "+this.number;
    }
    assignLeader(student){
        if(this.number==student.klass.number){
            this.leader=student;
            student.id=0;
            if(this.teacher){
                console.log('I am '+this.teacher.name+'. I know '+student.name+' become Leader of Class '+student.klass.number+'.');
            }
        }
        else console.log('It is not one of us.');
    }
    appendMember(student){
        if(student.klass!=this){
            student.klass=this;
            if(this.teacher){
                if(this.teacher.isTeaching(student)){
                    console.log('I am '+this.teacher.name+'. I know '+student.name+' has joined Class '+student.klass.number+'.');
                }
            }
        }
    }
    registerAssignLeaderListener(teacher){
        this.teacher=teacher;
    }
    registerJoinListener(teacher){
        this.teacher=teacher;
    }
    isIn(student){
        if(student.klass.number==this.number){
            return true;
        }
        else {
            return false;
        }
    }
}



